In [71]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
In [2]:
my_data = np.loadtxt('myGAMA_ALL_AB_ABSOL_MAGS_clean_plus_short.csv', delimiter=',', dtype=str)
In [3]:
my_dictionary = {}
for i in range(len(my_data[0, :])): # Converting numpy array into dictionary
my_dictionary[my_data[0, i]] = np.array(my_data[0 + 1:, i], dtype=str)
In [4]:
print my_data.shape
print my_data.size
print my_data[0,:]
In [5]:
redshift = my_dictionary['Z_HELIO'].astype(float)
fuv_band = my_dictionary['MAG_AB_FUV'].astype(float)
nuv_band = my_dictionary['MAG_AB_NUV'].astype(float)
u_band = my_dictionary['MAG_AB_U'].astype(float)
g_band = my_dictionary['MAG_AB_G'].astype(float)
r_band = my_dictionary['MAG_AB_R'].astype(float)
mag_abs_r = my_dictionary['MAG_ABSOLUTE_R'].astype(float)
stellar_mass = my_dictionary['MASS_k0'].astype(float)
sex_index_r = my_dictionary['SEX_INDEX_R'].astype(float) #SEx Sérsic Index
sex_index_h = my_dictionary['SEX_INDEX_H'].astype(float) #SEx Sérsic Index
gal_index_r = my_dictionary['GAL_INDEX_R'].astype(float) #Galfit Sérsic Index
gal_index_h = my_dictionary['GAL_INDEX_H'].astype(float) #Galfit Sérsic Index
z_prob = my_dictionary['PROB'].astype(float)
sfr = my_dictionary['SFR'].astype(float)
b300 = my_dictionary['B300_k0'].astype(float)
b1000 = my_dictionary['B1000_k0'].astype(float)
balmer_dec = my_dictionary['BALMER_DECREMENT'].astype(float)
uv_class = my_dictionary['UV_CLASS_YI2011'].astype(str)
In [6]:
z_min=0.06
z_max=0.40
In [7]:
indexes = np.arange(redshift.size)
index_clean = indexes[(r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)
*((fuv_band-nuv_band)>(-20))*(gal_index_h>0)]
In [8]:
index_all = indexes[(r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)
*((fuv_band-nuv_band)>(-20))*(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min)]
In [9]:
index_uvup = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band-r_band)>5.4)
*(fuv_band-nuv_band<0.9)*(fuv_band-r_band<6.6)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)
*(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min))
In [10]:
index_rsf = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band)<5.4)
*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min))
In [11]:
index_uvweak = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band) > 5.4)
*((fuv_band-r_band)>6.6)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)
*(z_prob>0.85)*(redshift>=z_min))
In [12]:
index_redsequence = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band-r_band)>5.4)
*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)*(z_prob>0.85)
*(redshift>=z_min))
In [106]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plot01, = plt.plot((nuv_band - r_band)[index_all], (fuv_band - nuv_band)[index_all], 'o', color = '#fec44f',
alpha=0.7, label="RSF")
plot02, = plt.plot((nuv_band - r_band)[index_redsequence], (fuv_band - nuv_band)[index_redsequence], 'o',
color = '#feb24c', alpha=0.7, label="UV Weak")
plot03, = plt.plot((nuv_band - r_band)[index_uvup], (fuv_band - nuv_band)[index_uvup], 'o', color = '#f03b20',
alpha=0.7, label="UV upturn")
plt.legend(numpoints=10, loc='best', fontsize=18)
plt.text(-4.5, 8, r"RSF", fontsize=18)
plt.text(-4.5, -3, r"RSF", fontsize=18)
plt.text(6.5, 8, r"UV Weak", fontsize=18)
plt.text(6.5, -3, r"UV upturn", fontsize=20)
plt.axvline(x=5.4, color='black', linewidth=2.)
plt.axhline(y=0.9, color='black', linewidth=2.)
plt.xlabel("NUV-r", fontsize=20)
plt.ylabel("FUV-NUV", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.grid(alpha=0.40)
plt.savefig('./Figs/maglim_yi_diagram.pdf')
plt.savefig('./Figs/maglim_yi_diagram.png')
plt.show()
In [14]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plt.plot(redshift[index_redsequence], mag_abs_r[index_redsequence], 'o', alpha=0.7, color='#7570b3', label='Red Sequence (UV weak+upturn)')
plt.plot(redshift[index_uvup], mag_abs_r[index_uvup], 'o', alpha=0.7, color='#d95f02', label='UV Upturn')
plt.xlabel("Redshift", fontsize=15)
plt.ylabel("M$_r$", fontsize=15)
plt.legend(loc='best', numpoints=1, fontsize=20, frameon=False)
plt.axvline(x=z_max, color='black', linewidth=1.)
plt.axvline(x=z_min, color='black', linewidth=1.)
plt.tick_params('both', labelsize='15')
plt.xlim(0,0.5)
plt.grid(alpha=0.40)
plt.gca().invert_yaxis()
plt.savefig('./Figs/maglim_mag_z_uvcategories_zoom.pdf')
plt.savefig('./Figs/maglim_mag_z_uvcategories_zoom.png')
plt.show()
In [15]:
bins = np.arange(0, (redshift[index_clean]).max(), 0.05)
ratio_uvup_redseq = []
average_redshift = []
z_uv = []
z_rs = []
redshift_uvup = redshift[index_uvup]
for i in range(bins.size):
if i==0:
continue
else:
index_redseq_i = np.where((bins[i-1] <= redshift[index_redsequence]) * (redshift[index_redsequence] <= bins[i]))
index_uvup_i = np.where((bins[i-1] <= redshift_uvup) * (redshift_uvup <= bins[i]))
redshift_bin_redseq = redshift[index_redseq_i]
redshift_bin_uvup = redshift_uvup[index_uvup_i]
if (redshift_bin_redseq.size==0):
ratio_uvup_i = 0
print "There are no UV Upturn galaxies in this range of redshift: %.2f and %.2f" % (bins[i-1], bins[i])
else:
ratio_uvup_i = (np.float(redshift_bin_uvup.size) / np.float(redshift_bin_redseq.size)) *100
average_redshift_i = np.average((bins[i], bins[i-1]))
average_redshift.append(average_redshift_i)
z_uv.append(redshift_bin_uvup.size)
z_rs.append(redshift_bin_redseq.size)
ratio_uvup_redseq.append(ratio_uvup_i)
ratio_uvup_redseq = np.array(ratio_uvup_redseq)
z_uv = np.array(z_uv)
z_rs = np.array(z_rs)
average_redshift = np.array(average_redshift)
In [95]:
n_groups = bins.size
index = np.arange(1,n_groups,1)
sns.set_style('white')
plt.subplots(1,1, figsize=(10,7))
plt.bar(index[[ratio_uvup_redseq!=0]], ratio_uvup_redseq[[ratio_uvup_redseq!=0]], width=1., alpha=0.65, color='#e6550d', edgecolor='#e6550d')
for i in range(bins[[ratio_uvup_redseq!=0]].size +1):
plt.text(index[i]+0.2, ratio_uvup_redseq[i]+1.6, r"$\mathbf{\frac{%4d}{%4d}}$" % (z_uv[i], z_rs[i]), fontsize=20)
plt.xticks(index, bins)
plt.ylabel("% of UV Upturn Galaxies", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.xlim(0.5, bins[[ratio_uvup_redseq!=0]].size +3)
plt.ylim(0, 65)
plt.rcParams['mathtext.fontset'] = u'stixsans'
plt.savefig('./Figs/maglim_percentageuvup_redseq.pdf')
plt.savefig('./Figs/maglim_percentageuvup_redseq.png')
plt.show()
In [17]:
with plt.style.context("seaborn-whitegrid"):
plt.rcParams["axes.edgecolor"] = "0.15"
plt.rcParams["axes.linewidth"] = 1.25
plt.subplots(1,1, figsize=(10,7))
plt.plot(mag_abs_r[index_all], (nuv_band[index_all]- r_band[index_all]), 'o', color='gray', alpha=0.05, label='All galaxies')
plt.plot(mag_abs_r[index_uvup], (nuv_band[index_uvup] - r_band[index_uvup]), 'o', color='#e6550d', alpha=0.2, label='UV Upturn')
sns.kdeplot(mag_abs_r[index_all], (nuv_band[index_all]- r_band[index_all]), n_levels=50, shade=False,
cmap="Purples_d", cbar=True)
plt.xlabel("M$_r$", fontsize=15)
plt.ylabel("NUV-r", fontsize=15)
plt.tick_params('both', labelsize='15')
plt.legend(loc='best', numpoints=100, fontsize=20, frameon=False)
plt.savefig('./Figs/maglim_color_mag01.pdf')
plt.savefig('./Figs/maglim_color_mag01.png')
plt.show()
In [18]:
with plt.style.context("seaborn-whitegrid"):
plt.rcParams["axes.edgecolor"] = "0.15"
plt.rcParams["axes.linewidth"] = 1.25
plt.subplots(1,1, figsize=(10,7))
plt.plot(mag_abs_r[index_all], (g_band - r_band)[index_all], 'o', color='gray', alpha=0.05, label='All galaxies')
plt.plot(mag_abs_r[index_uvup], (g_band - r_band)[index_uvup], 'o', color='#e6550d', alpha=0.2, label='UV Upturn')
sns.kdeplot(mag_abs_r[index_all], (g_band - r_band)[index_all], n_levels=50, shade=False,
cmap="Purples_d", cbar=True)
plt.ylim(-1., 4.)
plt.xlim()
plt.xlabel("M$_r$", fontsize=15)
plt.ylabel("g-r", fontsize=15)
plt.tick_params('both', labelsize='15')
plt.legend(loc='best', numpoints=100, fontsize=20, frameon=False)
plt.savefig('./Figs/maglim_color_mag02.pdf')
plt.savefig('./Figs/maglim_color_mag02.png')
plt.show()
In [19]:
bins_sersic = np.arange(0, gal_index_h.max(), 0.5)
sns.set_style("white")
plt.subplots(1,1, figsize=(10,7))
plt.hist(gal_index_h[index_rsf][[gal_index_r[index_rsf]<=10]], color='#fec44f', alpha=0.4, bins=bins_sersic, log=True, label='RSF Objects')
plt.hist(gal_index_h[index_redsequence][[gal_index_r[index_redsequence]<=10]], color='#feb24c', alpha=0.8, bins=bins_sersic, log=True, label='Red Sequence objects')
plt.hist(gal_index_h[index_uvup][[gal_index_r[index_uvup]<=10]], color='#f03b20', alpha=0.8, bins=bins_sersic, log=True, label='UV Upturn')
plt.xlabel("Sersic Index (UKIDSS H band)", fontsize=20)
plt.ylabel("Frequency", fontsize=20)
plt.tick_params('both', labelsize='15')
# plt.xlim(0,11)
plt.legend(loc='best', numpoints=1, fontsize=20, frameon=False)
plt.savefig('./Figs/maglim_sersic_dist.pdf')
plt.show()
In [20]:
# bins_sfr = np.arange(0, sfr[index_redsequence].max(), 1E17)
plt.subplots(1,1, figsize=(10,7))
plt.semilogy(redshift[index_redsequence], sfr[index_redsequence], 'o', color='#feb24c', alpha=0.8, label='Red-Sequence')
plt.semilogy(redshift[index_uvup], sfr[index_uvup], 'o', color='#f03b20', alpha=0.6, label='UV Upturn')
plt.legend(loc='best', fontsize=15)
plt.ylabel("SFR", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='15')
plt.xlim(0, 0.45)
plt.ylim(0, 1E8)
plt.show()
In [21]:
print sfr[index_redsequence].max()
print np.average(sfr[index_redsequence])
In [22]:
bxplt = {}
bxplt['UV_class'] = uv_class[index_redsequence]
bxplt['MAG_ABS_R'] = mag_abs_r[index_redsequence]
bxplt['redshift'] = redshift[index_redsequence]
bxplt = pd.DataFrame(bxplt)
In [23]:
bins = np.arange(0, (redshift[index_clean]).max(), 0.05)
In [24]:
print bins
bins_average = []
for i in range(bins.size-1):
bins_average.append(np.average([bins[i+1], bins[i]]))
bins_average = np.array(bins_average)
print bins_average
In [90]:
z_cut = pd.cut(bxplt['redshift'], bins = np.array(bins), labels=list(bins[0:-1]))
palette = ['#feb24c', '#f03b20']
plt.subplots(1,1, figsize=(10,7))
plot01 = sns.boxplot(x=z_cut, y='MAG_ABS_R', hue='UV_class', notch=True, palette=palette, data=bxplt, fliersize=4)
plt.setp(plot01.artists, alpha=.8)
handles, _ = plot01.get_legend_handles_labels()
plt.legend(handles, ["UV Weak", "UV Upturn"], fontsize=20)
plt.xlim(0,bins[[ratio_uvup_redseq!=0]].size+1)
plt.ylabel("M$_r$", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.gca().invert_yaxis()
plt.savefig('./Figs/boxplots_legend.png')
plt.savefig('./Figs/boxplots_legend.pdf')
plt.show()
In [26]:
plt.subplots(1,1, figsize=(10,7))
plt.hist((u_band[index_redsequence]-r_band[index_redsequence]), bins=10, log=True, color='#feb24c', alpha=0.6)
plt.hist((u_band[index_uvup]-r_band[index_uvup]), bins=10, log=True, color='#f03b20', alpha=0.6)
plt.ylabel("Freqency", fontsize=20)
plt.xlabel("u-r", fontsize=20)
plt.tick_params('both', labelsize='15')
plt.show()
In [ ]: